package com.acme.bankapp.domain;

import com.acme.bankapp.domain.accounts.Account;
import com.acme.bankapp.domain.accounts.AccountType;
import com.acme.bankapp.domain.accounts.CheckingAccount;
import com.acme.bankapp.domain.accounts.SavingsAccount;

/**
 * 
 * Holds information about the client's Name, Gender and Account.
 * Provides methods to get client info.
 * 
 */
public class Client {

	private Account account;
	private String name;
	private Gender gender;

	/**
	 * Constructs client by name and gender with a Savings account.
	 * @param name full name.
	 * @param gender desired gender.
	 */
	public Client(String name, Gender gender) {
		account = new SavingsAccount(); 
		
		this.name = name;
		this.gender = gender;
	
	}
	
	/**
	 * Constructs client by name and gender with a specified type account.
	 * @param name full name.
	 * @param gender desired gender.
	 * @param accountType specified account type. 
	 * @param overdraft Overdraft value to be set (optional).
	 */
	public Client(String name, Gender gender, AccountType accountType, double... overdraft) {
		this(name, gender);
		
		switch (accountType) {
		case SAVINGS:
			account = new SavingsAccount();
			break;
		case CHECKING:
			if (overdraft.length > 0) {
				account = new CheckingAccount(overdraft[0]);				
			} else {
				account = new CheckingAccount(0.);
			}
			break;
		default:
			account = new SavingsAccount();
		}
	}
	
	
	/** 
	 * Provides single-line description of form:
	 * Name, Gender: Balance.
	 */
	@Override
	public String toString() {
		return "" + name + ", " + gender + ": " + account.getBalance();
	}
	
	/**
	 * @return String salutation (ex.: Mr. Bill Gates).
	 */
	public String getSalutation() {
		return "" + gender + " " + getName();
	}
	
	/**
	 * @return Client's name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Sets the name equal to the specified String.
	 * @param name Name to be set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return clients Gender.
	 */
	public Gender getGender() {
		return gender;
	}
	
	/**
	 * Sets specified gender. 
	 * @param gender Gender to be set.
	 */
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	
	/**
	 * @return Account object. 
	 */
	public Account getAccount() {
		return account;
	}

}
